<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex align-stretch benben-position-layout flex recommendCommodityList_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex align-center justify-between recommendCommodityList_fd0_0'>
					<view class='flex align-center' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
						<text class='fu-iconfont2  recommendCommodityList_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view style="font-size: 36rpx;font-weight: 500;">预约</view>
					<view class="recommendCommodityList_fd0_0_c0_c0"></view>
				</view>
			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<view class="loading_css" v-if="isShow">
				<u-loading size="36" color="#F35D2A"></u-loading>
				<view>加载中</view>
			</view>
			<block v-else>
				<view class="coach_view" v-if="course_type == 2">
					<view class="coach_img">
						<image :src="staff_info.image" mode="aspectFill"></image>
					</view>
					<view class="coach_content">
						<view class="coach_content_1">{{staff_info.name}}</view>
						<view class="">
							<u-rate :disabled="true" :count="5" v-model="staff_info.stars" active-color="#FC5830"
								inactive-color="#C1C1C1" gutter="4" size="20"></u-rate>
						</view>
					</view>
				</view>
				<view class="input_content">
					<view class="input_item_one" @tap.stop="show=true">
						<view class="input_item_one_label">
							选择预约时间
						</view>
						<view class="input_item_one_value">
							<input v-model="change_time" :disabled="true" placeholder="请选择" placeholder-style="color:#B4B4B4;font-size:32rpx;"
								type="text">
							<view class="input_item_one_icon">
								<u-icon name="arrow-right" color="#BFBFBF" size="26"></u-icon>
							</view>
						</view>
					</view>
					<view class="input_item_one" v-if="course_type == 1 || course_type == 3" @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/shouye/oneAppointment/coachList?aid=${aid}`">
						<view class="input_item_one_label">
							<text>选择教练</text>
							<text v-if="course_type == 1">(选填)</text>
						</view>
						<view class="input_item_one_value">
							<input v-model="coachInfo.name" :disabled="true" placeholder="请选择" placeholder-style="color:#B4B4B4;font-size:32rpx;"
								type="text">
							<view class="input_item_one_icon">
								<u-icon name="arrow-right" color="#BFBFBF" size="26"></u-icon>
							</view>
						</view>
					</view>
					<view class="input_item_one">
						<view class="input_item_one_label">
							联系人
						</view>
						<view class="input_item_one_value">
							<input v-model="receiver_name" placeholder="请输入联系人姓名" placeholder-style="color:#B4B4B4;font-size:32rpx;" type="text" maxlength="14">
						</view>
					</view>
					<view class="input_item_one">
						<view class="input_item_one_label">
							联系电话
						</view>
						<view class="input_item_one_value">
							<input v-model="receiver_mobile" placeholder="请输入联系电话" placeholder-style="color:#B4B4B4;font-size:32rpx;" type="text" maxlength="11">
						</view>
					</view>
				</view>
				<view class="submit_btn" @tap.stop="postAppoment">
					<text>确认提交</text>
				</view>
			</block>
		</view>
		
		<!-- 选择时间 -->
		<u-select confirm-color="#333" cancel-color="#bfbfbf" :safe-area-inset-bottom="true" v-model="show" mode="mutil-column-auto" :list="timeList" child-name="child" @confirm="confirm"></u-select>

	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	import reservation from "@/components/reservation/reservation.vue"
	export default {
		components: {
			reservation
		},

		data() {
			return {
				isShow: false,
				show: false,
				count: 5,
				value: 4,
				course_type: 1, // 课程类型：1=单节课，2=团体课，3=私教课
				aid: "", // 课程id
				staff_info: {
					label: []
				}, // 教练信息
				timeList: [],
				change_time: "",
				class_time: "",  // 预约时间
				receiver_name: "", // 联系人
				receiver_mobile: "",  // 联系电话
				coachInfo: {
					id: "",
					name: ""
				},  // 选择的教练
				is_submit: false,
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				course_type,
				aid
			} = options;
			if (course_type !== undefined) this.course_type = course_type;
			if (aid !== undefined) this.aid = aid;
			this.staff_info = uni.getStorageSync('staff_info');
			if (this.course_type == 2) {
				this.coachInfo.id = this.staff_info.staff_id;
				this.coachInfo.name = this.staff_info.name;
			}
			console.log(this.staff_info);
			this.getTime();
			
			uni.$on('select', res => {
				this.coachInfo.id = res.id;
				this.coachInfo.name = res.name;
			})
		},
		onUnload() {
			uni.$off('select');
		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		// 下拉刷新
		onPullDownRefresh() {

		},
		// 上拉加载
		onReachBottom() {

		},
		onPageScroll(e) {

		},
		methods: {
			// 预约时间  post65b74d7262c69
			getTime() {
				this.$api.post(global.apiUrls.post65b74d7262c69, {
					course_type: this.course_type
				}).then(res => {
					if (res.data.code == 1) {
						this.timeList = res.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			confirm(e) {
				this.class_time = e[0].value + ' ' + e[1].value;
				this.change_time = e[0].label + ' ' + e[1].label;
			},
			// 提交预约
			postAppoment() {
				if (this.is_submit) return;
				if (!this.class_time) {
					this.$message.info('请选择预约时间');
					return false;
				}
				if (this.course_type == 3) {
					if (!this.coachInfo.id) {
						this.$message.info('请选择教练');
						return false;
					}
				}
				if (!this.receiver_name) {
					this.$message.info('请输入联系人');
					return false;
				}
				if (!this.receiver_mobile) {
					this.$message.info('请输入联系电话');
					return false;
				}
				if (!validate(this.receiver_mobile, 'phone')) {
					this.$message.info('请输入正确的联系电话');
					return false;
				}
				this.is_submit = true;
				this.$api.post(global.apiUrls.post65b74f1c89979, {
					course_id: this.aid,
					data_type: 1,
					staff_id: this.coachInfo.id,
					class_time: this.class_time,
					receiver_name: this.receiver_name,
					receiver_mobile: this.receiver_mobile
				}).then(res => {
					this.$message.info(res.data.msg);
					if (res.data.code == 1) {
						setTimeout(() => {
							this.is_submit = false;
							uni.redirectTo({
								url: '/pages/shouye/oneAppointment/yuyueSuccess'
							})
						}, 800)
					} else {
						this.is_submit = false;
					}
				})
			},
			
		}
	};
</script>
<style lang="scss" scoped>
	.submit_btn {
		width: 638rpx;
		height: 80rpx;
		background: #F35D2A;
		border-radius: 44rpx;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 80rpx;
		text-align: center;
		position: fixed;
		left: 56rpx;
		bottom: 40rpx;
		color: #FFFFFF;
	}

	.coach_view {
		background: #FFFFFF;
		padding: 32rpx;
		display: flex;
		align-items: center;

		.coach_img {
			width: 120rpx;
			height: 120rpx;
			margin-right: 24rpx;

			image {
				width: 100%;
				height: 100%;
				border-radius: 50%;
			}
		}

		.coach_content {
			.coach_content_1 {
				margin-bottom: 20rpx;
				font-size: 32rpx;
				font-weight: 500;
			}
		}

	}

	.input_content {
		background: #FFFFFF;
		padding: 0 32rpx;

		.input_item_one {
			display: flex;
			align-items: center;
			padding: 32rpx 0;
			border-bottom: 1px solid #eee;

			.input_item_one_label {
				font-size: 32rpx;
				color: #666666;
			}

			.input_item_one_value {
				flex: 1;
				display: flex;
				align-items: center;

				input {
					width: 100%;
					text-align: right;
					font-size: 32rpx;
				}

				.input_item_one_icon {
					margin-left: 16rpx;
				}
			}
		}
	}

	.index_fd1_0 {
		width: 750rpx;
		height: 750rpx;
		position: relative;

		.play_btn {
			width: 64rpx;
			height: 64rpx;
			position: absolute;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -50%);
		}
	}

	.swiper_num {
		width: 70rpx;
		height: 41rpx;
		background: rgba(0, 0, 0, 0.16);
		border-radius: 21rpx;
		position: absolute;
		right: 24rpx;
		bottom: 26rpx;
		z-index: 10;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;

		.swiper_num_1 {
			font-size: 32rpx;
		}

		.swiper_num_2 {
			font-size: 24rpx;
		}
	}

	.searchye_fd0_0_c1_c1 {
		margin: 0rpx 0rpx 0rpx 16rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #333;
		flex: 1;
		height: 100%;
		padding: 0 48rpx 0 0;
	}

	.searchye_fd0_0_c1_c0 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchye_fd0_0_c1 {
		background: #F9F9F9;
		background-size: 100% auto !important;
		border-radius: 36rpx 36rpx 36rpx 36rpx;
		width: 686rpx;
		height: 64rpx;
		margin: 0 32rpx;
		padding: 0 24rpx;
		position: relative;
	}

	.close_btn {
		width: 40rpx;
		height: 40rpx;
		position: absolute;
		top: 50%;
		transform: translateY(-50%);
		right: 16rpx;
	}

	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background-size: 100% auto;
		background-color: #f8f8f8;
	}

	.recommendCommodityList_flex_0 {
		width: 750rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto;
		background: #fff;
	}

	.recommendCommodityList_fd0_0_c1_c1 {
		font-size: 28rpx;
		font-weight: 400;
		color: var(--benbenFontColor0);
		margin: 0rpx 0rpx 0rpx 16rpx;
		width: 336rpx;
	}

	.recommendCommodityList_fd0_0_c1_c0 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.recommendCommodityList_fd0_0_c1 {
		background: #F9F9F9;
		height: 64rpx;
		width: 436rpx;
		border-radius: 34rpx 34rpx 34rpx 34rpx;
		padding: 0rpx 24rpx 0rpx 24rpx;
		margin: 0rpx 0rpx 0rpx 32rpx;
	}

	.recommendCommodityList_fd0_0_c0_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
		width: 50rpx;
	}

	.recommendCommodityList_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
		width: 100%;
	}

	.recommendCommodityList_flex_1 {
		background: #FFFFFF;
	}

	.recommendCommodityList_titlefd1_0_c0_c4 {
		margin: 0rpx 68rpx 0rpx 68rpx;
	}

	.recommendCommodityList_titlefd1_0_c0_c5 {
		margin: 0rpx 68rpx 0rpx 68rpx;
	}

	.recommendCommodityList_titleItemfd1_0_c0_c3_c0 {
		// font-size: 28rpx;
		font-weight: 400;
	}

	.recommendCommodityList_titlefd1_0_c0_c3 {
		margin: 0rpx 64rpx 0rpx 64rpx;
		// font-size: 32rpx;
		font-weight: 500;
	}

	.recommendCommodityList_linefd1_0_c0 {
		background: #F35D2A;
		width: 40rpx;
		height: 5rpx;
		top: 84rpx;
		background-size: 100% auto !important;
		border-radius: 3rpx 3rpx 0rpx 0rpx;
	}

	.checkTitlefd1_0_c0 {
		font-weight: 500 !important;
		font-size: 32rpx !important;
		color: #333 !important;
	}

	::v-deep .recommendCommodityList_benbenTabsfd1_0_c0 {
		background: #fff;
		// width: 750rpx;
		height: 90rpx;
		white-space: nowrap;
		text-align: center;
	}

	.recommendCommodityList_fd1_0 {
		// padding: 0rpx 32rpx 0rpx 32rpx;
		justify-content: center;
	}

	.recommendCommodityList_flex_2 {
		background-size: 100% auto;
		padding: 0rpx 24rpx 0rpx 24rpx;
	}

	.recommendCommodityList_fd2_0 {
		background: var(--benbenbgColor1);
	}

	.recommendCommodityList_flex_3 {
		background-size: 100% auto;
		padding: 0rpx 24rpx 0rpx 24rpx;
	}

	.recommendCommodityList_fd3_0_c0_c2_c0 {
		width: 44rpx;
		height: 44rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.recommendCommodityList_fd3_0_c0_c2 {
		position: absolute;
		right: 20rpx;
		top: 20rpx;
	}

	.recommendCommodityList_fd3_0_c0_c1_c1_c3 {
		color: #666666;
		font-size: 24rpx;
		font-weight: 400;
		max-width: 45rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.recommendCommodityList_fd3_0_c0_c1_c1_c2 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 13rpx 0rpx auto;
	}

	.recommendCommodityList_fd3_0_c0_c1_c1_c1 {
		color: #666666;
		font-size: 24rpx;
		font-weight: 400;
		margin: 0rpx 0rpx 0rpx 12rpx;
	}

	.recommendCommodityList_fd3_0_c0_c1_c1_c0 {
		width: 40rpx;
		height: 40rpx;
		border-radius: 20rpx;
	}

	.recommendCommodityList_fd3_0_c0_c1_c0 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 500;
		padding: 19rpx 0rpx 24rpx 0rpx;
	}

	.recommendCommodityList_fd3_0_c0_c1 {
		padding: 0rpx 25rpx 0rpx 20rpx;
	}

	.recommendCommodityList_fd3_0_c0_c0 {
		width: 335rpx;
		height: 450rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.recommendCommodityList_fd3_0_c0 {
		background: rgba(247, 246, 244, 1);
		padding: 0rpx 0rpx 24rpx 0rpx;
		background-size: 100% auto;
		position: relative;
	}

	.recommendCommodityList_flex_4 {
		background: var(--benbenbgColor1);
		padding: 0rpx 30rpx 0rpx 30rpx;
		background-size: 100% auto !important;
	}

	.recommendCommodityList_fd4_0_c2_1 {
		border: 1px solid #AD3823;
		background: rgba(173, 56, 35, 1);
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		width: 172rpx;
		line-height: 64rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor3);
		height: 64rpx;
	}

	.recommendCommodityList_fd4_0_c2 {
		border: 1px solid #AD3823;
		background: var(--benbenbgColor1);
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		width: 172rpx;
		line-height: 64rpx;
		font-size: 32rpx;
		color: rgba(173, 56, 35, 1);
		height: 64rpx;
	}

	.recommendCommodityList_fd4_0_c1_c1_c1 {
		background: var(--benbenbgColor6);
		width: 1rpx;
		height: 30rpx;
		margin: 0rpx 10rpx 0rpx 10rpx;
		transform: scaleX(0.5);
	}

	.recommendCommodityList_fd4_0_c1_c1_c0_c1 {
		margin: 0rpx 0rpx 0rpx 10rpx;
	}

	.recommendCommodityList_fd4_0_c1_c1 {
		color: #999999;
		font-size: 24rpx;
		line-height: 33rpx;
		font-weight: 400;
	}

	.recommendCommodityList_fd4_0_c1_c0 {
		color: #000000;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 40rpx;
		margin: 0rpx 0rpx 16rpx 0rpx;
	}

	.recommendCommodityList_fd4_0_c0 {
		width: 108rpx;
		height: 108rpx;
		border-radius: 54rpx;
		margin: 0rpx 23rpx 0rpx 0rpx;
	}

	.recommendCommodityList_fd4_0 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}


	.littleTheatre_fd2_0_c1_c2_c0_c0 {
		color: #AD3823;
		font-size: 28rpx;
		font-weight: 400;
	}

	.littleTheatre_fd2_0_c1_c2_c0 {
		background: #FFFFFF;
		width: 144rpx;
		height: 52rpx;
		// transform: translateY(-12rpx);
		position: absolute;
		bottom: 0;
		right: 0;
		border-radius: 24rpx 16rpx 0 0;
	}

	.littleTheatre_fd2_0_c1_c1_c1 {
		color: #333333;
		font-size: 34rpx;
		font-weight: 400;
		margin: 15rpx 0rpx 4rpx 0rpx;
	}

	.littleTheatre_fd2_0_c1_c1_c0 {
		color: #333333;
		font-size: 48rpx;
		font-weight: 400;
	}

	.littleTheatre_fd2_0_c1_c1 {
		margin: 56rpx 0rpx 0rpx 0rpx;
	}

	.littleTheatre_fd2_0_c1_c0 {
		width: 56rpx;
		height: 56rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		position: absolute;
		left: 24rpx;
		top: 24rpx;
	}

	.littleTheatre_fd2_0_c1 {
		// background: url(https://www.guochaoxiaoju.com/uploads/mini/514.png) no-repeat;
		background-size: 100% 220rpx;
		background-repeat: no-repeat;
		position: relative;
		margin: 0rpx 0rpx 24rpx 0rpx;
		height: 220rpx;
	}





	.otherFollow_fd1_1_c2_2 {
		border: 1px solid #62889B;
		background: #F8F8F8;
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		width: 172rpx;
		line-height: 64rpx;
		font-size: 32rpx;
		color: rgba(98, 136, 155, 1);
		height: 64rpx;
	}

	.otherFollow_fd1_1_c2_1 {
		border: 1px solid #AD3823;
		background: var(--benbenbgColor2);
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		width: 172rpx;
		line-height: 64rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor3);
		height: 64rpx;
	}

	.otherFollow_fd1_1_c2 {
		border: 1px solid #AD3823;
		background: #F8F8F8;
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		width: 172rpx;
		line-height: 64rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor4);
		height: 64rpx;
	}

	.otherFollow_fd1_1_c1_c1_c1 {
		background: var(--benbenbgColor6);
		width: 1rpx;
		height: 30rpx;
		margin: 0rpx 10rpx 0rpx 10rpx;
		transform: scaleX(0.5);
	}

	.otherFollow_fd1_1_c1_c1_c0_c1 {
		margin: 0rpx 0rpx 0rpx 10rpx;
	}

	.otherFollow_fd1_1_c1_c1 {
		color: #999999;
		font-size: 24rpx;
		line-height: 33rpx;
		font-weight: 400;
	}

	.otherFollow_fd1_1_c1_c0 {
		color: #000000;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 40rpx;
		margin: 0rpx 0rpx 16rpx 0rpx;
	}

	.otherFollow_fd1_1_c0 {
		width: 108rpx;
		height: 108rpx;
		border-radius: 54rpx;
		margin: 0rpx 23rpx 0rpx 0rpx;
	}

	.otherFollow_fd1_1 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}
</style>